package rs.ac.uns.ftn.informatika.mbs2.e11031.etaksi.servlet;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import rs.ac.uns.ftn.informatika.mbs2.e11031.etaksi.dao.KorisnikDao;

@SuppressWarnings("serial")
public class OdjavaKontroler extends HttpServlet {

	@EJB
	private KorisnikDao cKorisnikDao;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		cKorisnikDao.ocisti();
		HttpSession session = req.getSession();
		session.removeAttribute("korisnik");

		// povratak na pocetnu stranicu
		resp.sendRedirect(resp.encodeRedirectURL("./jsp/prijava.jsp"));
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
